<template>
    <div class="app-container">
        <div class="block">
            <el-row  :gutter="20">
                <el-col :span="4">
                    <el-input v-model="listQuery.id" size="mini" placeholder="请输入id"></el-input>
                </el-col>
                <el-col :span="4">
                    <el-input v-model="listQuery.title" size="mini" placeholder="请输入标题"></el-input>
                </el-col>
                <el-col :span="4" >
                  <el-select v-model="listQuery.classifyId" placeholder="请选择分类" size="mini">
                    <el-option v-for="item in classifys"
                               :key="item.id"
                               :label="item.name"
                               :value="item.id"
                    ></el-option>
                  </el-select>
                </el-col>
                <el-col :span="4" >
                  <el-select v-model="listQuery.state" placeholder="请选择状态" size="mini">
                      <el-option
                        v-for="item in options"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                      ></el-option>
                  </el-select>
                </el-col>
                <el-col :span="6">
                    <el-button type="success" size="mini" icon="el-icon-search" @click.native="search">{{ $t('button.search') }}</el-button>
                    <el-button type="primary" size="mini" icon="el-icon-refresh" @click.native="reset">{{ $t('button.reset') }}</el-button>
                </el-col>
            </el-row>
            <br>
            <el-row>
                <el-col :span="24">

                </el-col>
            </el-row>
        </div>


        <el-table :data="list" v-loading="listLoading" element-loading-text="Loading" border fit highlight-current-row
                  @current-change="handleCurrentChange">
          <el-table-column label="id">
            <template slot-scope="scope">
              {{scope.row.id}}
            </template>
          </el-table-column>
          <el-table-column label="分类">
              <template slot-scope="scope">
                  <span v-if="scope.row.classifyId == 1">跑腿</span>
                  <span v-else-if="scope.row.classifyId == 2">家政</span>
                  <span v-else-if="scope.row.classifyId == 3">维修</span>
                  <span v-else>其他</span>
                </template>
            </el-table-column>
          <el-table-column label="标题">
              <template slot-scope="scope">
                    {{scope.row.title}}
                </template>
            </el-table-column>
            <el-table-column label="任务总数">
                <template slot-scope="scope">
                    {{scope.row.num}}
                </template>
            </el-table-column>
            <el-table-column label="剩余数量">
                <template slot-scope="scope">
                    {{scope.row.lastNum}}
                </template>
            </el-table-column>
            <el-table-column label="状态">
                <template slot-scope="scope">
                    <span v-if="scope.row.state==0">待支付</span>
                    <span v-else-if="scope.row.state==1">进行中</span>
                    <span v-else-if="scope.row.state==2">审核中</span>
                    <span v-else-if="scope.row.state==3">待修改</span>
                    <span v-else-if="scope.row.state==5">已结束</span>
                    <span v-else-if="scope.row.state==6">暂停中</span>
                    <span v-else>{{scope.row.state}}</span>
                </template>
            </el-table-column>
            <el-table-column label="任务简述">
                <template slot-scope="scope">
                    {{scope.row.sketch}}
                </template>
            </el-table-column>
            <el-table-column label="完成时限（小时）">
                <template slot-scope="scope">
                    {{scope.row.timeLimit}}
                </template>
            </el-table-column>
            <el-table-column label="任务结束时间">
                <template slot-scope="scope">
                    {{scope.row.endTime}}
                </template>
            </el-table-column>
            <el-table-column label="城市编码">
                <template slot-scope="scope">
                    {{scope.row.cityId}}
                </template>
            </el-table-column>
            <el-table-column label="操作">
                <template slot-scope="scope">
                    <!--<el-button type="text" size="mini" icon="el-icon-edit" @click.native="editItem(scope.row)" v-permission="['/help/task/update']">{{ $t('button.edit') }}</el-button>
                    <el-button type="text" size="mini" icon="el-icon-delete" @click.native="removeItem(scope.row)" v-permission="['/help/task/delete']">{{ $t('button.delete') }}</el-button>-->
                  <el-button type="text" size="mini"  icon="el-icon-view" @click.native="view(scope.row)">{{ $t('button.view') }}</el-button>
                  <el-button v-if="scope.row.state==2" type="text" size="mini"  icon="el-icon-postcard" @click.native="audit(scope.row)">{{ $t('button.audit') }}</el-button>
                </template>
            </el-table-column>
        </el-table>

        <el-pagination
                background
                layout="total, sizes, prev, pager, next, jumper"
                :page-sizes="[10, 20, 50, 100,500]"
                :page-size="listQuery.limit"
                :total="total"
                @size-change="changeSize"
                @current-change="fetchPage"
                @prev-click="fetchPrev"
                @next-click="fetchNext">
        </el-pagination>

        <el-dialog
                :title="formTitle"
                :visible.sync="formVisible"
                width="50%">
                <el-dialog
                  width="30%"
                  title="审核不通过"
                  :visible.sync="innerVisible"
                  append-to-body>
                  <el-form ref="form" label-width="20%">
                    <el-form-item label="不通过原因">
                      <el-input v-model="failureReason"></el-input>
                    </el-form-item>
                  </el-form>
                    <span slot="footer" class="dialog-footer">
                      <el-button  @click="innerVisible = false">取 消</el-button>
                      <el-button  type="primary" @click="noPass(selRow.id)">确认</el-button>
                    </span>
                </el-dialog>
                <el-row>
                    <el-col :span="4">
                      <div class="hint">标 题</div>
                    </el-col>
                  <el-col :span="20">
                    <div class="color-black">{{selRow.title}}</div>
                  </el-col>
                </el-row>
                <el-row>
                    <el-col :span="4">
                      <div class="hint">类 型</div>
                    </el-col>
                  <el-col :span="20">
                    <div class="color-black" v-if="selRow.classifyId == 1">跑腿</div>
                    <div class="color-black" v-else-if="selRow.classifyId == 2">家政</div>
                    <div class="color-black" v-else-if="selRow.classifyId == 3">维修</div>
                    <div class="color-black" v-else>其他</div>
                  </el-col>
                </el-row>
                <el-row>
                    <el-col :span="4">
                      <div class="hint">任 务 简 述</div>
                    </el-col>
                  <el-col :span="20">
                    <div class="color-black">{{selRow.sketch}}</div>
                  </el-col>
                </el-row>
                <el-row>
                    <el-col :span="4">
                      <div class="hint">单 价</div>
                    </el-col>
                  <el-col :span="20">
                    <div class="color-red">￥{{selRow.price}}</div>
                  </el-col>
                </el-row>
                <el-row>
                    <el-col :span="4">
                      <div class="hint">完 成 时 限</div>
                    </el-col>
                  <el-col :span="20">
                    <div class="color-black">{{selRow.timeLimit}}小时</div>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="4">
                    <div class="hint">步 骤</div>
                  </el-col>
                </el-row>
                <el-row :span="24">
                  <div class="block">
                    <el-timeline>
                      <el-timeline-item v-for="item in taskSteps" placement="top">
                        <el-card>
                          <h4>{{item.stepExplain}}</h4>
                          <div class="demo-image__preview" v-if="item.idFiles != [] && item.idFiles.length > 0" style="float: left;margin-bottom: 5px">
                            <el-image v-for="id in item.idFiles"
                              style="width: 100px; height: 100px;margin-right: 5px;"
                              :src="'/dev-api/file/getImgStream?idFile='+id"
                              :preview-src-list="['/dev-api/file/getImgStream?idFile='+id]">
                            </el-image>
                          </div>
                        </el-card>
                      </el-timeline-item>
                    </el-timeline>
                  </div>
                </el-row>
                <el-row>
                  <el-col :span="4">
                    <div class="hint">收集凭证</div>
                  </el-col>
                </el-row>
              <el-row v-for="proof in taskPoofs" style="padding-left: 50px">
                <el-col :span="12">
                  <div class="hint-proof">凭证名称</div>
                  <div class="hint-proof color-rosybrown">{{proof.name}}</div>
                </el-col>
                <el-col :span="12">
                  <div class="hint-proof">凭证类型</div>
                  <div class="hint-proof color-rosybrown"><span v-if="proof.type == 1">文字</span> <span v-if="proof.type == 2">图片</span></div>
                </el-col>
              </el-row>
          <span slot="footer" class="dialog-footer">
            <el-button v-if="isAudit" @click="formVisible = false">取 消</el-button>
            <el-button v-if="!isAudit" @click="formVisible = false">关 闭</el-button>
            <el-button v-if="isAudit" type="primary" @click="pass(selRow.id)">通 过</el-button>
            <el-button v-if="isAudit" type="info" @click="innerVisible = true">不通过</el-button>
          </span>
        </el-dialog>
    </div>
</template>

<script src="./helpTask.js"></script>
<style type="text/css">
  .hint{
    height: 30px;
    height: 30px;
    text-align: right;
    padding-right: 10px;
  }
  .hint-proof{
    width: 50%;
    height: 30px;
    text-align: right;
    padding-right: 10px;
  }
  .color-rosybrown{
    color: rosybrown;
    font-weight: bold;
  }
  .color-black{
    color: black;
    font-weight: bold;
  }
  .color-red{
    color: red;
    font-weight: bold;
  }
  .el-icon-circle-close{
    color: #ffffff;
  }
</style>

<style rel="stylesheet/scss" lang="scss" scoped>
    @import "src/styles/common.scss";
</style>

